package com.nbsaas.boot.wms.rest.resource;

import com.nbsaas.boot.wms.api.apis.WarehouseApi;
import com.nbsaas.boot.wms.data.entity.Warehouse;
import com.nbsaas.boot.wms.api.domain.request.WarehouseRequest;
import com.nbsaas.boot.wms.api.domain.response.WarehouseResponse;
import com.nbsaas.boot.wms.api.domain.simple.WarehouseSimple;
import com.nbsaas.boot.wms.rest.convert.WarehouseSimpleConvert;
import com.nbsaas.boot.wms.rest.convert.WarehouseEntityConvert;
import com.nbsaas.boot.wms.rest.convert.WarehouseResponseConvert;
import com.nbsaas.boot.wms.data.repository.WarehouseRepository;

import java.io.Serializable;

import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;

/**
 * 仓库-业务接口实现
 */
@Transactional
@Service
public class WarehouseResource extends BaseResource<Warehouse, WarehouseResponse, WarehouseSimple, WarehouseRequest> implements WarehouseApi {

    @Resource
    private WarehouseRepository warehouseRepository;

    @Override
    public JpaRepositoryImplementation<Warehouse, Serializable> getJpaRepository() {
        return warehouseRepository;
    }

    @Override
    public Function<Warehouse, WarehouseSimple> getConvertSimple() {
        return new WarehouseSimpleConvert();
    }

    @Override
    public Function<WarehouseRequest, Warehouse> getConvertForm() {
        return new WarehouseEntityConvert();
    }

    @Override
    public Function<Warehouse, WarehouseResponse> getConvertResponse() {
        return new WarehouseResponseConvert();
    }


}


